﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index2</title>
    <script src="@Url.Content("~/Scripts/jquery.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.easyui.min.js")" type="text/javascript"></script>
    @Styles.Render("~/Content/css")
    @Styles.Render("~/Content/themes/blue/css")
    
    <script>
        $(function () {
            jQuery("#RightAccordion").accordion({ //初始化accordion
                fillSpace: true,
                fit: true,
                border: false,
                animate: false
            });
            $.post("/Menu/GetTreeByEasyui", { "id": "0" }, //获取第一层目录
               function (data) {
                   if (data == "0") {
                       window.location = "/Account";
                   }
                   $.each(data, function (i, e) {//循环创建手风琴的项
                       var id = e.id;
                       $('#RightAccordion').accordion('add', {
                           title: e.text,
                           content: "<ul id='tree" + id + "' ></ul>",
                           selected: true,
                           iconCls: e.iconCls//e.Icon
                       });
                       $.parser.parse();
                       $.post("/Menu/GetTreeByEasyui?id=" + id, function (data) {//循环创建树的项
                           $("#tree" + id).tree({
                               data: data,
                               onBeforeExpand: function (node, param) {
                                   $("#tree" + id).tree('options').url = "/Menu/GetTreeByEasyui?id=" + node.id;
                               },
                               onClick: function (node) {
                                   if (node.state == 'closed') {
                                       $(this).tree('expand', node.target);
                                   } else if (node.state == 'open') {
                                       $(this).tree('collapse', node.target);
                                   } else {
                                       var tabTitle = node.text;
                                       var url = "../../" + node.attributes;
                                       var icon = node.iconCls;
                                       addTab(tabTitle, url, icon);
                                   }
                               }
                           });
                       }, 'json');
                   });
               }, "json");
        });
    </script>

</head>
<body>
    <div id="RightAccordion" class="easyui-accordion" >
        
    </div>
</body>
</html>
